﻿<!--#include file="inc/common.asp" -->
<%
'Blog评论编辑页面
'
'author: evan zhao
'


  dim content_id, blogItem, parent_id,parentComment,comment_id, comment, count, i

  content_id = trim(request("content_id"))
  set blogItem = new BlogItemClass    

  parent_id = trim(request("parent_id"))
  set parentComment = new BlogCommentClass

  comment_id = request("comment_id")
  set comment = new BlogCommentClass

  if comment_id<>"" then
      comment_id = clng(comment_id)
      comment.load(comment_id)
      if comment.userId <> userObj.userId and not userRightObj.canManage then
          message("不能编辑别人的留言")
      end if
      content_id = comment.itemId
      parent_id=comment.parentId
  end if

  if content_id="" then
    message("文章不存在")
    return
  end if
  
  content_id = clng(content_id)
  
  if  blogItem.load(content_id) = false then
    message("文章不存在")
    call closeDB()
    response.end
  end if
  
  if isNumeric(parent_id) then
    parent_id = clng(parent_id)
    if parent_id<>0 then
        parentComment.load(parent_id)
    else
        parent_id=""
    end if   
  else
    parent_id=""   
  end if  

  'response.AddHeader "Last-Modified", DateToGMT(blogItem.updateTime)
  'response.Expires = 0
  'response.CacheControl = "no-cache"
%>

<HTML><HEAD><TITLE><%=blogObj.blogTitle%><%
    if blogCatObj.catName<>"" then
        response.write(" -" & blogCatObj.catName)
    end if
%>-<%=blogItem.title%>
</TITLE>
<META http-equiv=Content-Type content="text/html; charset=GBK">
<% 
if not isNull(blogItem.excerpt) then
%>
<META Name="description" Content="<%=replace(blogItem.excerpt,"""","&quot;")%>">
<%
 end if
%>
<link rel="stylesheet" href="styles.css" type="text/css" />
<script language=javascript>
    var isIE = false
    if (document.all){
        isIE = true;
    }

    function RTELoaded(editor){
        if (editor==commentEditor){
            if (form1.detail.value!=""){
                editor.setHTML(form1.detail.value);
            }
        }
        
    }

    function deleteComment(comment_id){
        if (!confirm("确定删除吗？")){
            return false;
        }
        theform = document.getElementById("form1");
        theform.actionType.value="doDelete";
        theform.comment_id.value=comment_id;
        theform.submit();
    }
    function saveReply(){
        theform = document.getElementById("form1");
        if (isIE){
            if(commentEditor.getText()!=""  || commentEditor.getHTML().indexOf("<IMG")>-1){
                theform.detail.value = commentEditor.getHTML();
            }else{
                theform.detail.value = "";
            }
        }
        if (theform.detail.value==""){
            alert("请输入回复内容")
            return;
        }
        theform.actionType.value="doSave";
        theform.submit();
    }
    function saveTrack(){
        theform = document.getElementById("form2");
        if (theform.url.value==""){
            alert("请输入文章URL")
            return;
        }
        theform.actionType.value="doSave";
        theform.submit();
    }
    function deleteTrack(track_id){
        if (!confirm("确定删除吗？")){
            return false;
        }
        theform = document.getElementById("form2");
        theform.actionType.value="doDelete";
        theform.track_id.value=track_id;
        theform.submit();
    }
</script>
<style type="text/css">

BUTTON {
	border:1px dotted #98ccd0;background-color:#ffffff;font-family:verdana;font-size:9pt;height:18px;color: #346784;
}

</style>
</HEAD>
<BODY>
<center>
<DIV id=container style=" width:80%; background-color:transparent" align=center>
    <DIV id=banner>
        <h1><a href="index.asp?blog_id=<%=blogObj.blogId%>"><%=blogObj.blogTitle%></a>
<%
    if blogCatObj.catName<>"" then
%>
    -<a href="index.asp?blog_id=<%=blogCatObj.blogId%>&cat_id=<%=blogCatObj.catId%>"><%=blogCatObj.catName%></a>
<%
    end if
%></h1>
        <h2><%=filterHTML(blogObj.blogDesc)%></h2>
    </DIV>
        <br>
        <div class=content style="  background-color:#ffffff; width:100%">  
        
        
<%
    dim  start_date_str, end_date_str, insert_time_str

    if isEmpty(parent_id) or parent_id="" then
        start_date_str = FORMATDATETIME(blogItem.startDate, vbShortDate)
        end_date_str = FORMATDATETIME(blogItem.endDate, vbShortDate)
        insert_time_str = FORMATDATETIME(blogItem.insertTime, vbShortDate)
        %>  
            <h2>
        <%
            if start_date_str = insert_time_str and end_date_str = insert_time_str then
                response.write (insert_time_str)
            elseif  start_date_str =  end_date_str then
                response.write (end_date_str)
            else
                response.write (start_date_str & " ~ " & end_date_str)
            end if     
        %>
            </h2>
            <h3><%=blogItem.title%></h3>
            <div>
            <%
            if blogItem.isSecret then 
                response.write("<p>--保密内容--</p>")
            end if
            if not blogItem.isSecret or (userObj.userId<>"" and userObj.userId=blogItem.userId) or userRightObj.canReadSecret then
                response.write("<p>"& blogItem.excerpt & "</p>")            
                response.write(blogItem.detail)
                if not isNull(blogItem.more) and not isEmpty(blogItem.more) then
                    response.write("<a name=more></a><br>")
                    response.write(blogItem.more)
                end if
            end if    
            %>
            </div>
            <div class="posted">
                <%
                    if blogItem.userId="" or blogItem.userId=0 then
                        response.write blogItem.userName
                     else
                %>     
                     <a href=user.asp?user_id=<%=blogItem.userId%>&blog_id=<%=blogItem.blogId%>&cat_id=<%=blogItem.catId%>&pageno=<%=request("pageno")%>><%= blogItem.userName%></a>
                <%
                     end if                
                %>&nbsp;
<%
        if start_date_str = insert_time_str and end_date_str = insert_time_str then
            response.write FORMATDATETIME(blogItem.insertTime,vbLongTime)
        else
            response.write blogItem.insertTime
        end if
    else

        insert_time_str = FORMATDATETIME(parentComment.insertTime, vbShortDate)
        %>  
            <h2><%=insert_time_str%></h2>
            <div>
            <%
            if parentComment.isSecret then 
                response.write("<p>--悄悄话--</p>")
            end if
            if not parentComment.isSecret or (userObj.userId<>"" and userObj.userId=parentComment.userId) or userRightObj.canReadSecret then
                response.write(parentComment.detail)
            end if    
            %>
            </div>
            <div class="posted">
                <%
                    if parentComment.userId="" or parentComment.userId=0 then
                        response.write parentComment.userName
                     else
                %>     
                     <a href=user.asp?user_id=<%=parentComment.userId%>&blog_id=<%=blogObj.blogId%>&cat_id=<%=blogCatObj.catId%>&pageno=<%=request("pageno")%>><%=parentComment.userName%></a>
                <%
                     end if                
                %>&nbsp;
<%
            response.write FORMATDATETIME(parentComment.insertTime,vbLongTime)
    end if  
    
%> 
            </div>    
            <hr size=1 style='border:1px dotted #98ccd0;margin-bottom: 15px;'>

            <b>发表评论：</b>
            <div>
            <a name="reply"></a>
            <br>
            <form name="form1" id="form1" method="post" action="reply.asp">
              <input name="actionType" type="hidden"  />
              
              <input name="blog_id" type="hidden" value="<%=blogObj.blogId%>" />
              <input name="cat_id" type="hidden" value="<%=blogCatObj.catId%>" />
              <input name="content_id" type="hidden" value="<%=content_id%>" />
              <input name="parent_id" type="hidden" value="<%=parent_id%>">
              <input name="comment_id" type="hidden"  value="<%=comment_id%>" />
              <input name="pageno" type="hidden" value="<%=request("pageno")%>" />
    
            <p>  
              用户名：<%
                if userObj.isFound then
                    response.write "<a href=userinfo.asp?blog_id=" & blogObj.blogId & "&cat_id=" & blogCatObj.catId & "&pageno=" & request("pageno") & ">" & userObj.userName & "</a>"
                else                    
            %><input name="username" type="text" size="20" value="<%=userObj.userName%>" />
              &nbsp;密码：<input name="password" type="password" size="20" value="" />（如不登录密码请留空）
              <br />
              Email ：<input name="email"  type="text" size="20" value="<%=userObj.email%>" />
              &nbsp;主页：<input name="web_url" type="text" size="20" value="<%=userObj.webUrl%>" />
            <%
                end if
            %>  
            </p>  
              您的回复：<br />
        	<script language="javascript">
        	    document.write('<textarea name=detail rows=12 cols=38');
        	    if (isIE){
        	        document.write (' style="display:none" ');
        	    }
        	    document.write('>');
        	</script><%=Server.HTMLEncode(comment.detail)%></textarea>
        	<script language="javascript">
        	    if (isIE){
        		    document.write('<IFRAME id="commentEditor" Name="commentEditor" style="WIDTH: 500px; HEIGHT: 360px"  SRC="rte/rte.htm"></IFRAME>'); 
        		    document.write('<input type=hidden name="use_rte" value="true">');
        	    }
        	</script>

	              <br />
              <% if userObj.userId<>"" then  %>
              	<input name="is_secret" type="checkbox" value="true" <% if parentComment.isSecret or comment.isSecret then response.write("checked") end if %> >悄悄话</input>
              <% end if  %> 
              <br />
              <br />
              <input name="submitBtn" type="button" onclick="saveReply()" value="&nbsp;&nbsp;回 复&nbsp;&nbsp;"  />
              <input  type="button" onclick="history.back()" value="&nbsp;&nbsp;后 退&nbsp;&nbsp;"  /> 
              <input  type="button" onclick="document.location.href='detail.asp?blog_id=<%=blogObj.blogId%>&cat_id=<%=blogCatObj.catId%>&content_id=<%=content_id%>&pageno=<%=request("pageno")%>&#comment<%=parent_id%>'" value="&nbsp;&nbsp;返 回&nbsp;&nbsp;"  />
            </form>        
    	    </div>
        <p>&nbsp;</p>
        </div><!--end of content-->

        <p>&nbsp;</p>

        
</DIV>    
</center>    
</BODY>
</HTML>

<!--#include file="inc/end.asp" -->